package com.mmall.common;

import com.mmall.pojo.SysUser;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author wangtengyu
 * @Create 2018-03-13-14:19
 */
public class RequestHolder {
    private static final ThreadLocal<SysUser> userholder=new ThreadLocal<SysUser>();

    private static final ThreadLocal<HttpServletRequest> requestHolder=new ThreadLocal<HttpServletRequest>();

    public static void add(SysUser user){
        userholder.set(user);
    }

    public static void add(HttpServletRequest request){
        requestHolder.set(request);
    }

    public static SysUser getCurrentUser(){
        return userholder.get();
    }

    public static HttpServletRequest getCurrentRequest(){
        return requestHolder.get();
    }

    public static void remove(){
        userholder.remove();
        requestHolder.remove();
    }
}
